package com.gcs.k8s01.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;


/**
 * Swagger API 说明
 *
 * @author Ryan
 */
@EnableSwagger2
@Configuration
public class SwaggerConfig {

    @Value("${spring.swagger.enabled}")
    private boolean enabled;

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .contact(new Contact("gcs", "", "wangbo16@westaport.com"))
                .title(" K8S API ")
                .description("用户管理接口。")
                .version("1.0")
                .build();
    }

    @Bean
    public Docket docketBasic(){
        return new Docket(DocumentationType.SWAGGER_2)
                .enable(enabled)
                .apiInfo(apiInfo())
                .groupName("用户管理").select()
                .apis(RequestHandlerSelectors.basePackage("com.gcs.k8s01.controller"))
                .paths(PathSelectors.any()).build();
    }

}
